<template>
  <transition name="slide-fade">
    <div v-if="visible" class="notification" :class="{ 'notification--error': type === 'error' }">
      <div class="notification__content">
        <h3 class="notification__title">{{ title }}</h3>
        <p class="notification__message">{{ message }}</p>
      </div>
      <button class="notification__close" @click="close">×</button>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Notification',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '提醒'
    },
    message: {
      type: String,
      required: true
    },
    type: {
      type: String,
      default: 'info'
    }
  },
  methods: {
    close() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  padding: 16px;
  min-width: 300px;
  max-width: 400px;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.notification__content {
  flex: 1;
}

.notification__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.notification__message {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.notification__close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  margin-left: 16px;
  color: #999;
}

.notification--error {
  border-left: 4px solid #f56c6c;
}

.slide-fade-enter-active {
  transition: all 0.3s ease;
}

.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}

.slide-fade-enter,
.slide-fade-leave-to {
  transform: translateX(30px);
  opacity: 0;
}
</style> 